import gevent
from gevent import monkey
import time

#打补丁
#如果不打补丁的话，下面就必须写上gevent.sleep(0.5)
# monkey.patch_all()

def f(n):
    for i in range(n):
        print(gevent.getcurrent(), i)
        #用来模拟一个耗时操作
        time.sleep(1)

gevent.joinall([
    gevent.spawn(f, 5),
    gevent.spawn(f, 5),
    gevent.spawn(f, 5)
])